package com.leyou.search.controller;

import com.leyou.common.vo.PageResult;
import com.leyou.search.dto.GoodsDTO;
import com.leyou.search.dto.SearchRequest;
import com.leyou.search.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("/page")
    public ResponseEntity<PageResult<GoodsDTO>> goodsPageQuery(@RequestBody SearchRequest request){
        return ResponseEntity.ok(goodsService.goodsPageQuery(request));
    }


    @PostMapping("/filter")
    public ResponseEntity<Map<String, List<?>>> goodsFilter(@RequestBody SearchRequest request){
        return ResponseEntity.ok(goodsService.goodsFilter(request));
    }

}
